package hu.bme.mit.inf.eclipse.v37zen.awesome.diagram.part;

import hu.bme.mit.inf.eclipse.v37zen.awesome.Awesome;
import hu.bme.mit.inf.eclipse.v37zen.awesome.AwesomePackage;
import hu.bme.mit.inf.eclipse.v37zen.awesome.BottomBox;
import hu.bme.mit.inf.eclipse.v37zen.awesome.Desktop;
import hu.bme.mit.inf.eclipse.v37zen.awesome.LeftBox;
import hu.bme.mit.inf.eclipse.v37zen.awesome.Menu;
import hu.bme.mit.inf.eclipse.v37zen.awesome.Menuitem;
import hu.bme.mit.inf.eclipse.v37zen.awesome.RightBox;
import hu.bme.mit.inf.eclipse.v37zen.awesome.TopBox;
import hu.bme.mit.inf.eclipse.v37zen.awesome.diagram.edit.parts.AwesomeEditPart;
import hu.bme.mit.inf.eclipse.v37zen.awesome.diagram.edit.parts.BottomBoxEditPart;
import hu.bme.mit.inf.eclipse.v37zen.awesome.diagram.edit.parts.DesktopBottomBoxCompartmentEditPart;
import hu.bme.mit.inf.eclipse.v37zen.awesome.diagram.edit.parts.DesktopEditPart;
import hu.bme.mit.inf.eclipse.v37zen.awesome.diagram.edit.parts.DesktopLeftBoxCompartmentEditPart;
import hu.bme.mit.inf.eclipse.v37zen.awesome.diagram.edit.parts.DesktopMenusCompartmentEditPart;
import hu.bme.mit.inf.eclipse.v37zen.awesome.diagram.edit.parts.DesktopRightBoxCompartmentEditPart;
import hu.bme.mit.inf.eclipse.v37zen.awesome.diagram.edit.parts.DesktopTopBoxCompartmentEditPart;
import hu.bme.mit.inf.eclipse.v37zen.awesome.diagram.edit.parts.LeftBoxEditPart;
import hu.bme.mit.inf.eclipse.v37zen.awesome.diagram.edit.parts.MenuEditPart;
import hu.bme.mit.inf.eclipse.v37zen.awesome.diagram.edit.parts.MenuMenuItemsCompartmentEditPart;
import hu.bme.mit.inf.eclipse.v37zen.awesome.diagram.edit.parts.MenuitemEditPart;
import hu.bme.mit.inf.eclipse.v37zen.awesome.diagram.edit.parts.MenuitemSubmenuEditPart;
import hu.bme.mit.inf.eclipse.v37zen.awesome.diagram.edit.parts.RightBoxEditPart;
import hu.bme.mit.inf.eclipse.v37zen.awesome.diagram.edit.parts.TopBoxEditPart;
import hu.bme.mit.inf.eclipse.v37zen.awesome.diagram.providers.AwesomeElementTypes;

import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.gmf.tooling.runtime.update.DiagramUpdater;

/**
 * @generated
 */
public class AwesomeDiagramUpdater {

	/**
	 * @generated
	 */
	public static List<AwesomeNodeDescriptor> getSemanticChildren(View view) {
		switch (AwesomeVisualIDRegistry.getVisualID(view)) {
		case AwesomeEditPart.VISUAL_ID:
			return getAwesome_1000SemanticChildren(view);
		case DesktopMenusCompartmentEditPart.VISUAL_ID:
			return getDesktopMenusCompartment_7001SemanticChildren(view);
		case DesktopTopBoxCompartmentEditPart.VISUAL_ID:
			return getDesktopTopBoxCompartment_7003SemanticChildren(view);
		case DesktopBottomBoxCompartmentEditPart.VISUAL_ID:
			return getDesktopBottomBoxCompartment_7004SemanticChildren(view);
		case DesktopRightBoxCompartmentEditPart.VISUAL_ID:
			return getDesktopRightBoxCompartment_7005SemanticChildren(view);
		case DesktopLeftBoxCompartmentEditPart.VISUAL_ID:
			return getDesktopLeftBoxCompartment_7006SemanticChildren(view);
		case MenuMenuItemsCompartmentEditPart.VISUAL_ID:
			return getMenuMenuItemsCompartment_7002SemanticChildren(view);
		}
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeNodeDescriptor> getAwesome_1000SemanticChildren(
			View view) {
		if (!view.isSetElement()) {
			return Collections.emptyList();
		}
		Awesome modelElement = (Awesome) view.getElement();
		LinkedList<AwesomeNodeDescriptor> result = new LinkedList<AwesomeNodeDescriptor>();
		{
			Desktop childElement = modelElement.getDesktop();
			int visualID = AwesomeVisualIDRegistry.getNodeVisualID(view,
					childElement);
			if (visualID == DesktopEditPart.VISUAL_ID) {
				result.add(new AwesomeNodeDescriptor(childElement, visualID));
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	public static List<AwesomeNodeDescriptor> getDesktopMenusCompartment_7001SemanticChildren(
			View view) {
		if (false == view.eContainer() instanceof View) {
			return Collections.emptyList();
		}
		View containerView = (View) view.eContainer();
		if (!containerView.isSetElement()) {
			return Collections.emptyList();
		}
		Desktop modelElement = (Desktop) containerView.getElement();
		LinkedList<AwesomeNodeDescriptor> result = new LinkedList<AwesomeNodeDescriptor>();
		for (Iterator<?> it = modelElement.getMenus().iterator(); it.hasNext();) {
			Menu childElement = (Menu) it.next();
			int visualID = AwesomeVisualIDRegistry.getNodeVisualID(view,
					childElement);
			if (visualID == MenuEditPart.VISUAL_ID) {
				result.add(new AwesomeNodeDescriptor(childElement, visualID));
				continue;
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	public static List<AwesomeNodeDescriptor> getDesktopTopBoxCompartment_7003SemanticChildren(
			View view) {
		if (false == view.eContainer() instanceof View) {
			return Collections.emptyList();
		}
		View containerView = (View) view.eContainer();
		if (!containerView.isSetElement()) {
			return Collections.emptyList();
		}
		Desktop modelElement = (Desktop) containerView.getElement();
		LinkedList<AwesomeNodeDescriptor> result = new LinkedList<AwesomeNodeDescriptor>();
		{
			TopBox childElement = modelElement.getTopBox();
			int visualID = AwesomeVisualIDRegistry.getNodeVisualID(view,
					childElement);
			if (visualID == TopBoxEditPart.VISUAL_ID) {
				result.add(new AwesomeNodeDescriptor(childElement, visualID));
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	public static List<AwesomeNodeDescriptor> getDesktopBottomBoxCompartment_7004SemanticChildren(
			View view) {
		if (false == view.eContainer() instanceof View) {
			return Collections.emptyList();
		}
		View containerView = (View) view.eContainer();
		if (!containerView.isSetElement()) {
			return Collections.emptyList();
		}
		Desktop modelElement = (Desktop) containerView.getElement();
		LinkedList<AwesomeNodeDescriptor> result = new LinkedList<AwesomeNodeDescriptor>();
		{
			BottomBox childElement = modelElement.getBottomBox();
			int visualID = AwesomeVisualIDRegistry.getNodeVisualID(view,
					childElement);
			if (visualID == BottomBoxEditPart.VISUAL_ID) {
				result.add(new AwesomeNodeDescriptor(childElement, visualID));
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	public static List<AwesomeNodeDescriptor> getDesktopRightBoxCompartment_7005SemanticChildren(
			View view) {
		if (false == view.eContainer() instanceof View) {
			return Collections.emptyList();
		}
		View containerView = (View) view.eContainer();
		if (!containerView.isSetElement()) {
			return Collections.emptyList();
		}
		Desktop modelElement = (Desktop) containerView.getElement();
		LinkedList<AwesomeNodeDescriptor> result = new LinkedList<AwesomeNodeDescriptor>();
		{
			RightBox childElement = modelElement.getRightBox();
			int visualID = AwesomeVisualIDRegistry.getNodeVisualID(view,
					childElement);
			if (visualID == RightBoxEditPart.VISUAL_ID) {
				result.add(new AwesomeNodeDescriptor(childElement, visualID));
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	public static List<AwesomeNodeDescriptor> getDesktopLeftBoxCompartment_7006SemanticChildren(
			View view) {
		if (false == view.eContainer() instanceof View) {
			return Collections.emptyList();
		}
		View containerView = (View) view.eContainer();
		if (!containerView.isSetElement()) {
			return Collections.emptyList();
		}
		Desktop modelElement = (Desktop) containerView.getElement();
		LinkedList<AwesomeNodeDescriptor> result = new LinkedList<AwesomeNodeDescriptor>();
		{
			LeftBox childElement = modelElement.getLeftBox();
			int visualID = AwesomeVisualIDRegistry.getNodeVisualID(view,
					childElement);
			if (visualID == LeftBoxEditPart.VISUAL_ID) {
				result.add(new AwesomeNodeDescriptor(childElement, visualID));
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	public static List<AwesomeNodeDescriptor> getMenuMenuItemsCompartment_7002SemanticChildren(
			View view) {
		if (false == view.eContainer() instanceof View) {
			return Collections.emptyList();
		}
		View containerView = (View) view.eContainer();
		if (!containerView.isSetElement()) {
			return Collections.emptyList();
		}
		Menu modelElement = (Menu) containerView.getElement();
		LinkedList<AwesomeNodeDescriptor> result = new LinkedList<AwesomeNodeDescriptor>();
		for (Iterator<?> it = modelElement.getMenuitems().iterator(); it
				.hasNext();) {
			Menuitem childElement = (Menuitem) it.next();
			int visualID = AwesomeVisualIDRegistry.getNodeVisualID(view,
					childElement);
			if (visualID == MenuitemEditPart.VISUAL_ID) {
				result.add(new AwesomeNodeDescriptor(childElement, visualID));
				continue;
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getContainedLinks(View view) {
		switch (AwesomeVisualIDRegistry.getVisualID(view)) {
		case AwesomeEditPart.VISUAL_ID:
			return getAwesome_1000ContainedLinks(view);
		case DesktopEditPart.VISUAL_ID:
			return getDesktop_2001ContainedLinks(view);
		case MenuEditPart.VISUAL_ID:
			return getMenu_3001ContainedLinks(view);
		case MenuitemEditPart.VISUAL_ID:
			return getMenuitem_3002ContainedLinks(view);
		case TopBoxEditPart.VISUAL_ID:
			return getTopBox_3003ContainedLinks(view);
		case BottomBoxEditPart.VISUAL_ID:
			return getBottomBox_3004ContainedLinks(view);
		case LeftBoxEditPart.VISUAL_ID:
			return getLeftBox_3005ContainedLinks(view);
		case RightBoxEditPart.VISUAL_ID:
			return getRightBox_3006ContainedLinks(view);
		}
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getIncomingLinks(View view) {
		switch (AwesomeVisualIDRegistry.getVisualID(view)) {
		case DesktopEditPart.VISUAL_ID:
			return getDesktop_2001IncomingLinks(view);
		case MenuEditPart.VISUAL_ID:
			return getMenu_3001IncomingLinks(view);
		case MenuitemEditPart.VISUAL_ID:
			return getMenuitem_3002IncomingLinks(view);
		case TopBoxEditPart.VISUAL_ID:
			return getTopBox_3003IncomingLinks(view);
		case BottomBoxEditPart.VISUAL_ID:
			return getBottomBox_3004IncomingLinks(view);
		case LeftBoxEditPart.VISUAL_ID:
			return getLeftBox_3005IncomingLinks(view);
		case RightBoxEditPart.VISUAL_ID:
			return getRightBox_3006IncomingLinks(view);
		}
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getOutgoingLinks(View view) {
		switch (AwesomeVisualIDRegistry.getVisualID(view)) {
		case DesktopEditPart.VISUAL_ID:
			return getDesktop_2001OutgoingLinks(view);
		case MenuEditPart.VISUAL_ID:
			return getMenu_3001OutgoingLinks(view);
		case MenuitemEditPart.VISUAL_ID:
			return getMenuitem_3002OutgoingLinks(view);
		case TopBoxEditPart.VISUAL_ID:
			return getTopBox_3003OutgoingLinks(view);
		case BottomBoxEditPart.VISUAL_ID:
			return getBottomBox_3004OutgoingLinks(view);
		case LeftBoxEditPart.VISUAL_ID:
			return getLeftBox_3005OutgoingLinks(view);
		case RightBoxEditPart.VISUAL_ID:
			return getRightBox_3006OutgoingLinks(view);
		}
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getAwesome_1000ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getDesktop_2001ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getMenu_3001ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getMenuitem_3002ContainedLinks(
			View view) {
		Menuitem modelElement = (Menuitem) view.getElement();
		LinkedList<AwesomeLinkDescriptor> result = new LinkedList<AwesomeLinkDescriptor>();
		result.addAll(getOutgoingFeatureModelFacetLinks_Menuitem_Submenu_4002(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getTopBox_3003ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getBottomBox_3004ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getLeftBox_3005ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getRightBox_3006ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getDesktop_2001IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getMenu_3001IncomingLinks(
			View view) {
		Menu modelElement = (Menu) view.getElement();
		Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer
				.find(view.eResource().getResourceSet().getResources());
		LinkedList<AwesomeLinkDescriptor> result = new LinkedList<AwesomeLinkDescriptor>();
		result.addAll(getIncomingFeatureModelFacetLinks_Menuitem_Submenu_4002(
				modelElement, crossReferences));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getMenuitem_3002IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getTopBox_3003IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getBottomBox_3004IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getLeftBox_3005IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getRightBox_3006IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getDesktop_2001OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getMenu_3001OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getMenuitem_3002OutgoingLinks(
			View view) {
		Menuitem modelElement = (Menuitem) view.getElement();
		LinkedList<AwesomeLinkDescriptor> result = new LinkedList<AwesomeLinkDescriptor>();
		result.addAll(getOutgoingFeatureModelFacetLinks_Menuitem_Submenu_4002(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getTopBox_3003OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getBottomBox_3004OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getLeftBox_3005OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<AwesomeLinkDescriptor> getRightBox_3006OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	private static Collection<AwesomeLinkDescriptor> getIncomingFeatureModelFacetLinks_Menuitem_Submenu_4002(
			Menu target,
			Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences) {
		LinkedList<AwesomeLinkDescriptor> result = new LinkedList<AwesomeLinkDescriptor>();
		Collection<EStructuralFeature.Setting> settings = crossReferences
				.get(target);
		for (EStructuralFeature.Setting setting : settings) {
			if (setting.getEStructuralFeature() == AwesomePackage.eINSTANCE
					.getMenuitem_Submenu()) {
				result.add(new AwesomeLinkDescriptor(setting.getEObject(),
						target, AwesomeElementTypes.MenuitemSubmenu_4002,
						MenuitemSubmenuEditPart.VISUAL_ID));
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<AwesomeLinkDescriptor> getOutgoingFeatureModelFacetLinks_Menuitem_Submenu_4002(
			Menuitem source) {
		LinkedList<AwesomeLinkDescriptor> result = new LinkedList<AwesomeLinkDescriptor>();
		Menu destination = source.getSubmenu();
		if (destination == null) {
			return result;
		}
		result.add(new AwesomeLinkDescriptor(source, destination,
				AwesomeElementTypes.MenuitemSubmenu_4002,
				MenuitemSubmenuEditPart.VISUAL_ID));
		return result;
	}

	/**
	 * @generated
	 */
	public static final DiagramUpdater TYPED_INSTANCE = new DiagramUpdater() {
		/**
		 * @generated
		 */
		@Override
		public List<AwesomeNodeDescriptor> getSemanticChildren(View view) {
			return AwesomeDiagramUpdater.getSemanticChildren(view);
		}

		/**
		 * @generated
		 */
		@Override
		public List<AwesomeLinkDescriptor> getContainedLinks(View view) {
			return AwesomeDiagramUpdater.getContainedLinks(view);
		}

		/**
		 * @generated
		 */
		@Override
		public List<AwesomeLinkDescriptor> getIncomingLinks(View view) {
			return AwesomeDiagramUpdater.getIncomingLinks(view);
		}

		/**
		 * @generated
		 */
		@Override
		public List<AwesomeLinkDescriptor> getOutgoingLinks(View view) {
			return AwesomeDiagramUpdater.getOutgoingLinks(view);
		}
	};

}
